using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.GamerServices;
using Arcadium.Graphics;

namespace Arcadium.Screens.Menus.Sidebar
{
    class SidebarPlayerList : SidebarComponent
    {

        public GamerCollection<NetworkGamer> Gamers { get; private set; }



        private SidebarMenuEntry[] menuEntries = new SidebarMenuEntry[4];

        public SidebarPlayerList(Vector2 startposition, float yInterval)
        {
            for (int i = 0; i < menuEntries.Length; i++)
                menuEntries[i] = new SidebarMenuEntry(null, 
                    startposition + i * Vector2.UnitY * yInterval, 
                    TextVerticalAlignment.Middle);
        }

        public void Load(GamerCollection<NetworkGamer> gamers)
        {
            Gamers = gamers;

            for (int i = 0; i < gamers.Count; i++)
                menuEntries[i].Text = gamers[i].Gamertag;
        }

        public void Draw(SpriteBatch spriteBatch, bool sidebarHasFocus)
        {
            foreach (SidebarMenuEntry menuEntry in menuEntries)
            {
                if (menuEntry.Text != null)
                    menuEntry.Draw(spriteBatch, sidebarHasFocus);
            }


            //// Player list
            //for (int i = 0; i < networkSession.AllGamers.Count; i++)
            //{
            //    spriteBatch.DrawString(ViewResource.MenuFont,
            //        networkSession.AllGamers[i].Gamertag,
            //        new Vector2(20 * View.ScreenScale.X, (600 + i * 138) * View.ScreenScale.Y),
            //        hasFocus && selectedItem == 2 + i ? Color.Red : Color.White, 0,
            //        new Vector2(0, ViewResource.MenuFont.LineSpacing) * View.ScreenScale / 2, View.ScreenScale, SpriteEffects.None, .5f);
            //}

        }

    }
}
